var data = cc.Class({

    init(){

        this.gold = 0 //该局获取金币
        this.bulletNum = 3 //子弹数量
        this.buttetType = 0 //子弹类型
        this.buttetAtk = 1  //攻击力

        //当前游戏关卡
        // cc.sys.localStorage.removeItem("myLevel")
        this.myLevel = cc.sys.localStorage.getItem("myLevel")
        if(this.myLevel == null) this.myLevel = 1


        // cc.sys.localStorage.removeItem("myGold")
        this.myGold = cc.sys.localStorage.getItem("myGold")
        if(this.myGold == null) this.myGold = 0

        cc.log("数据初始化完毕!")
    },

    //增加子弹数
    addBullet(num){
        this.bulletNum += num 
    },

    //本局获得金币
    getGold(num) {
        this.gold += num
        return utils.goldCrarryBit(this.gold)
    },

    //我的金币
    getMyGold(){
        cc.log("总金币：" + this.myGold)
        return utils.goldCrarryBit(this.myGold)
    },

    //增加金币
    addGold(gold){
        cc.log("新增金币：" + gold)
        this.myGold = parseInt(this.myGold)
        cc.sys.localStorage.setItem("myGold", this.myGold += gold)
    },

    //增加关卡
    addLevel(){
        this.myLevel = parseInt(this.myLevel) + 1
        cc.log("开启新关卡：" + this.myLevel)
        cc.sys.localStorage.setItem("myLevel", this.myLevel)
    },

})

window.data = new data()
window.data.init()




